﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace YJTTool.Common.Converts
{
    public class UpperIfEnglishConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && value is string && !string.IsNullOrEmpty(value.ToString()))
            {
                string input = value.ToString();
                if (string.IsNullOrWhiteSpace(input))
                {
                    return input;
                }

                // 判断输入是否为英文字符（包括大小写字母）
                bool isEnglish = input.All(c => Char.IsLetter(c) && (Char.IsLower(c) || Char.IsUpper(c)));

                if (isEnglish)
                {
                    return input.ToUpper(); // 转换为大写
                }

                return input;

            } 
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
